<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SpringBoot设计模式解析 - 技术小馆</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4, h5, h6 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .code-block {
            background: #282c34;
            border-radius: 8px;
            position: relative;
        }
        .code-header {
            background: rgba(0,0,0,0.3);
            padding: 8px 12px;
            border-top-left-radius: 8px;
            border-top-right-radius: 8px;
            display: flex;
            align-items: center;
        }
        .code-dot {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            margin-right: 6px;
        }
        .code-dot.red {
            background: #ff5f56;
        }
        .code-dot.yellow {
            background: #ffbd2e;
        }
        .code-dot.green {
            background: #27c93f;
        }
        .pattern-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .pattern-icon {
            transition: all 0.3s ease;
        }
        .pattern-card:hover .pattern-icon {
            transform: scale(1.1);
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col items-center text-center">
                <h1 class="text-4xl md:text-5xl font-bold mb-6">SpringBoot设计模式解析</h1>
                <p class="text-xl md:text-2xl mb-8 max-w-3xl leading-relaxed">
                    探索SpringBoot背后的设计哲学，从基础应用到架构之美
                </p>
                <div class="flex space-x-4">
                    <a href="#patterns" class="bg-white text-indigo-700 px-6 py-3 rounded-lg font-medium hover:bg-gray-100 transition duration-300">
                        <i class="fas fa-book-open mr-2"></i>开始探索
                    </a>
                    <a href="#summary" class="border-2 border-white text-white px-6 py-3 rounded-lg font-medium hover:bg-white hover:text-indigo-700 transition duration-300">
                        <i class="fas fa-lightbulb mr-2"></i>核心认知
                    </a>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl px-4 py-12">
        <!-- Introduction -->
        <section class="mb-16">
            <blockquote class="border-l-4 border-indigo-500 pl-6 py-2 italic text-gray-700 mb-8">
                "SpringBoot就像精心设计的乐高套装，设计模式就是那些标准接口的积木块。"
            </blockquote>
            <p class="text-lg text-gray-700 leading-relaxed">
                在SpringBoot的日常使用中，我们能看到各种注解和配置，但背后隐藏着许多经典设计模式的应用。理解这些模式不仅能让我们更高效地使用框架特性，还能编写出更优雅、可扩展的代码。
            </p>
        </section>

        <!-- Patterns Grid -->
        <section id="patterns" class="mb-20">
            <h2 class="text-3xl font-bold mb-8 text-center">SpringBoot中的六大设计模式</h2>
            
            <!-- Factory Pattern -->
            <div class="pattern-card bg-white rounded-xl shadow-md overflow-hidden mb-10 transition-all duration-300">
                <div class="md:flex">
                    <div class="md:w-1/3 p-6 flex items-center bg-indigo-50">
                        <div class="text-center w-full">
                            <div class="pattern-icon inline-block text-indigo-600 mb-4">
                                <i class="fas fa-industry text-6xl"></i>
                            </div>
                            <h3 class="text-2xl font-bold mb-2">工厂模式</h3>
                            <p class="text-indigo-700">对象的创建与使用分离</p>
                        </div>
                    </div>
                    <div class="md:w-2/3 p-6">
                        <div class="flex items-center mb-4">
                            <div class="w-3 h-3 rounded-full bg-indigo-500 mr-2"></div>
                            <h4 class="text-xl font-semibold">奶茶店的生产线</h4>
                        </div>
                        <p class="text-gray-700 mb-4">
                            想象一下你去奶茶店点单——你只需要告诉店员要"珍珠奶茶"，后厨就会自动完成煮茶、加料、封口整套流程。这就是工厂模式在SpringBoot中的体现。
                        </p>
                        <div class="mb-6">
                            <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1742613224905-c10272c7-98c4-48d5-93f1-5b89ee18bef1.png" alt="工厂模式示意图" class="rounded-lg shadow-sm w-full">
                        </div>
                        <div class="mb-6">
                            <h5 class="font-semibold mb-2 text-indigo-700 flex items-center">
                                <i class="fas fa-list-ul mr-2"></i>典型应用场景：
                            </h5>
                            <ul class="list-disc pl-5 space-y-1 text-gray-700">
                                <li>Bean的创建过程（ApplicationContext就是超级工厂）</li>
                                <li>第三方库的集成（如RedisTemplate的生成）</li>
                                <li>条件化配置（@Conditional系列注解）</li>
                            </ul>
                        </div>
                        <div class="code-block mb-4">
                            <div class="code-header">
                                <div class="code-dot red"></div>
                                <div class="code-dot yellow"></div>
                                <div class="code-dot green"></div>
                                <div class="text-gray-300 text-sm ml-2">MilkTeaFactory.java</div>
                            </div>
                            <pre class="text-gray-200 p-4 overflow-x-auto"><code>// 自定义奶茶工厂
@Configuration
public class MilkTeaFactory {
    
    @Bean
    @Scope("prototype")
    public MilkTea pearlMilkTea() {
        MilkTea tea = new MilkTea();
        tea.addIngredient("珍珠");
        tea.setSugarLevel(50);
        return tea;
    }
}</code></pre>
                        </div>
                        <p class="text-gray-700">
                            当你在Controller中@Autowired一个MilkTea对象时，SpringBoot就像奶茶店后厨一样，按配方为你制作好对象。这就是为什么我们几乎不需要自己new对象的原因。
                        </p>
                    </div>
                </div>
            </div>

            <!-- Singleton Pattern -->
            <div class="pattern-card bg-white rounded-xl shadow-md overflow-hidden mb-10 transition-all duration-300">
                <div class="md:flex">
                    <div class="md:w-1/3 p-6 flex items-center bg-blue-50">
                        <div class="text-center w-full">
                            <div class="pattern-icon inline-block text-blue-600 mb-4">
                                <i class="fas fa-crown text-6xl"></i>
                            </div>
                            <h3 class="text-2xl font-bold mb-2">单例模式</h3>
                            <p class="text-blue-700">全局唯一的对象实例</p>
                        </div>
                    </div>
                    <div class="md:w-2/3 p-6">
                        <div class="flex items-center mb-4">
                            <div class="w-3 h-3 rounded-full bg-blue-500 mr-2"></div>
                            <h4 class="text-xl font-semibold">公司的CEO</h4>
                        </div>
                        <p class="text-gray-700 mb-4">
                            公司里的CEO只能有一个，这就是单例模式的精髓。SpringBoot通过这个模式管理着最重要的核心组件。
                        </p>
                        <div class="mb-6">
                            <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1742613512323-77d55efa-dffd-4c28-9681-ed5980da66a8.png" alt="单例模式示意图" class="rounded-lg shadow-sm w-full">
                        </div>
                        <div class="mb-6">
                            <h5 class="font-semibold mb-2 text-blue-700 flex items-center">
                                <i class="fas fa-table mr-2"></i>实现方式对比表：
                            </h5>
                            <div class="overflow-x-auto">
                                <table class="min-w-full border border-gray-200">
                                    <thead class="bg-blue-50">
                                        <tr>
                                            <th class="px-4 py-2 text-left text-blue-700 border-b">方式</th>
                                            <th class="px-4 py-2 text-left text-blue-700 border-b">优点</th>
                                            <th class="px-4 py-2 text-left text-blue-700 border-b">典型应用</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr class="hover:bg-gray-50">
                                            <td class="px-4 py-2 border-b">@Bean注解</td>
                                            <td class="px-4 py-2 border-b">配置灵活</td>
                                            <td class="px-4 py-2 border-b">数据源配置</td>
                                        </tr>
                                        <tr class="hover:bg-gray-50">
                                            <td class="px-4 py-2 border-b">@Component注解</td>
                                            <td class="px-4 py-2 border-b">自动扫描</td>
                                            <td class="px-4 py-2 border-b">Service层组件</td>
                                        </tr>
                                        <tr class="hover:bg-gray-50">
                                            <td class="px-4 py-2 border-b">枚举实现</td>
                                            <td class="px-4 py-2 border-b">防反射攻击</td>
                                            <td class="px-4 py-2 border-b">全局状态管理</td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="code-block mb-4">
                            <div class="code-header">
                                <div class="code-dot red"></div>
                                <div class="code-dot yellow"></div>
                                <div class="code-dot green"></div>
                                <div class="text-gray-300 text-sm ml-2">UserService.java</div>
                            </div>
                            <pre class="text-gray-200 p-4 overflow-x-auto"><code>@Service // 这个注解让UserService成为单例
public class UserService {
    // 业务方法...
}

// 测试验证
@Test
void testSingleton() {
    UserService instance1 = context.getBean(UserService.class);
    UserService instance2 = context.getBean(UserService.class);
    assertSame(instance1, instance2); // 确认是同一个实例
}</code></pre>
                        </div>
                        <p class="text-gray-700">
                            单例模式节省了内存开销，但也需要注意线程安全问题。Spring通过Bean的作用域设计（@Scope）让开发者可以灵活控制。
                        </p>
                    </div>
                </div>
            </div>

            <!-- Template Method Pattern -->
            <div class="pattern-card bg-white rounded-xl shadow-md overflow-hidden mb-10 transition-all duration-300">
                <div class="md:flex">
                    <div class="md:w-1/3 p-6 flex items-center bg-green-50">
                        <div class="text-center w-full">
                            <div class="pattern-icon inline-block text-green-600 mb-4">
                                <i class="fas fa-clipboard-list text-6xl"></i>
                            </div>
                            <h3 class="text-2xl font-bold mb-2">模板方法模式</h3>
                            <p class="text-green-700">定义算法骨架，灵活扩展</p>
                        </div>
                    </div>
                    <div class="md:w-2/3 p-6">
                        <div class="flex items-center mb-4">
                            <div class="w-3 h-3 rounded-full bg-green-500 mr-2"></div>
                            <h4 class="text-xl font-semibold">红烧肉的烹饪步骤</h4>
                        </div>
                        <p class="text-gray-700 mb-4">
                            做红烧肉和糖醋排骨的步骤都是：准备食材→焯水→炒制→收汁。这就是模板方法模式——定义算法骨架，允许子类重写特定步骤。
                        </p>
                        <div class="mb-6">
                            <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1742613553083-5ec9e655-b16c-49ec-8131-2f36305cd082.png" alt="模板方法模式示意图" class="rounded-lg shadow-sm w-full">
                        </div>
                        <div class="mb-6">
                            <h5 class="font-semibold mb-2 text-green-700 flex items-center">
                                <i class="fas fa-check-circle mr-2"></i>Spring中的经典实现：
                            </h5>
                            <ul class="list-disc pl-5 space-y-1 text-gray-700">
                                <li>JdbcTemplate的execute方法</li>
                                <li>RestTemplate的请求处理流程</li>
                                <li>@Transactional的事务管理</li>
                            </ul>
                        </div>
                        <div class="code-block mb-4">
                            <div class="code-header">
                                <div class="code-dot red"></div>
                                <div class="code-dot yellow"></div>
                                <div class="code-dot green"></div>
                                <div class="text-gray-300 text-sm ml-2">CookingTemplate.java</div>
                            </div>
                            <pre class="text-gray-200 p-4 overflow-x-auto"><code>public abstract class CookingTemplate {
    // 模板方法（final防止被重写）
    public final void cook() {
        prepareIngredients();
        blanching();
        stirFry();
        thickenSauce();
    }
    
    // 抽象方法（必须由子类实现）
    protected abstract void prepareIngredients();
    
    // 默认实现（可选重写）
    protected void blanching() {
        System.out.println("焯水30秒");
    }
    
    // 其他步骤...
}

// 具体实现
@Component
public class BraisedPork extends CookingTemplate {
    @Override
    protected void prepareIngredients() {
        System.out.println("准备五花肉500g");
    }
}</code></pre>
                        </div>
                        <p class="text-gray-700">
                            下次使用JdbcTemplate时，你会注意到它已经帮你处理了连接获取、异常处理等通用逻辑，你只需要关注SQL执行本身。
                        </p>
                    </div>
                </div>
            </div>

            <!-- Proxy Pattern -->
            <div class="pattern-card bg-white rounded-xl shadow-md overflow-hidden mb-10 transition-all duration-300">
                <div class="md:flex">
                    <div class="md:w-1/3 p-6 flex items-center bg-purple-50">
                        <div class="text-center w-full">
                            <div class="pattern-icon inline-block text-purple-600 mb-4">
                                <i class="fas fa-user-tie text-6xl"></i>
                            </div>
                            <h3 class="text-2xl font-bold mb-2">代理模式</h3>
                            <p class="text-purple-700">控制对象访问的中间层</p>
                        </div>
                    </div>
                    <div class="md:w-2/3 p-6">
                        <div class="flex items-center mb-4">
                            <div class="w-3 h-3 rounded-full bg-purple-500 mr-2"></div>
                            <h4 class="text-xl font-semibold">明星的经纪人</h4>
                        </div>
                        <p class="text-gray-700 mb-4">
                            明星都有经纪人处理日常事务，这个经纪人就是代理对象。Spring AOP的核心机制正是基于动态代理。
                        </p>
                        <div class="mb-6">
                            <h5 class="font-semibold mb-2 text-purple-700 flex items-center">
                                <i class="fas fa-table mr-2"></i>代理类型对比：
                            </h5>
                            <div class="overflow-x-auto">
                                <table class="min-w-full border border-gray-200">
                                    <thead class="bg-purple-50">
                                        <tr>
                                            <th class="px-4 py-2 text-left text-purple-700 border-b">代理类型</th>
                                            <th class="px-4 py-2 text-left text-purple-700 border-b">实现方式</th>
                                            <th class="px-4 py-2 text-left text-purple-700 border-b">特点</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr class="hover:bg-gray-50">
                                            <td class="px-4 py-2 border-b">JDK动态代理</td>
                                            <td class="px-4 py-2 border-b">接口代理</td>
                                            <td class="px-4 py-2 border-b">性能较好</td>
                                        </tr>
                                        <tr class="hover:bg-gray-50">
                                            <td class="px-4 py-2 border-b">CGLIB代理</td>
                                            <td class="px-4 py-2 border-b">类继承</td>
                                            <td class="px-4 py-2 border-b">无需接口</td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="code-block mb-4">
                            <div class="code-header">
                                <div class="code-dot red"></div>
                                <div class="code-dot yellow"></div>
                                <div class="code-dot green"></div>
                                <div class="text-gray-300 text-sm ml-2">UserServiceProxy.java</div>
                            </div>
                            <pre class="text-gray-200 p-4 overflow-x-auto"><code>// 业务接口
public interface UserService {
    void register(User user);
}

// 目标类
@Service
public class UserServiceImpl implements UserService {
    @Override
    @Transactional // 事务代理的典型应用
    public void register(User user) {
        // 注册逻辑
    }
}

// 自动生成的代理类（伪代码）
public class UserServiceProxy implements UserService {
    private UserService target;
    
    public void register(User user) {
        startTransaction();
        try {
            target.register(user);
            commitTransaction();
        } catch (Exception e) {
            rollbackTransaction();
        }
    }
}</code></pre>
                        </div>
                        <p class="text-gray-700">
                            当你在方法上添加@Transactional注解时，Spring就会悄悄创建一个代理对象来管理事务。这就是为什么添加注解就能实现事务控制的原因。
                        </p>
                    </div>
                </div>
            </div>

            <!-- Observer Pattern -->
            <div class="pattern-card bg-white rounded-xl shadow-md overflow-hidden mb-10 transition-all duration-300">
                <div class="md:flex">
                    <div class="md:w-1/3 p-6 flex items-center bg-yellow-50">
                        <div class="text-center w-full">
                            <div class="pattern-icon inline-block text-yellow-600 mb-4">
                                <i class="fas fa-bell text-6xl"></i>
                            </div>
                            <h3 class="text-2xl font-bold mb-2">观察者模式</h3>
                            <p class="text-yellow-700">事件驱动的解耦设计</p>
                        </div>
                    </div>
                    <div class="md:w-2/3 p-6">
                        <div class="flex items-center mb-4">
                            <div class="w-3 h-3 rounded-full bg-yellow-500 mr-2"></div>
                            <h4 class="text-xl font-semibold">微信订阅号的通知</h4>
                        </div>
                        <p class="text-gray-700 mb-4">
                            就像微信订阅号，当博主发文时，所有粉丝都会收到通知。Spring的事件机制完美诠释了这一模式。
                        </p>
                        <div class="mb-6">
                            <h5 class="font-semibold mb-2 text-yellow-700 flex items-center">
                                <i class="fas fa-cube mr-2"></i>核心组件：
                            </h5>
                            <ul class="list-disc pl-5 space-y-1 text-gray-700">
                                <li>ApplicationEvent（事件）</li>
                                <li>ApplicationListener（监听器）</li>
                                <li>ApplicationEventPublisher（发布者）</li>
                            </ul>
                        </div>
                        <div class="code-block mb-4">
                            <div class="code-header">
                                <div class="code-dot red"></div>
                                <div class="code-dot yellow"></div>
                                <div class="code-dot green"></div>
                                <div class="text-gray-300 text-sm ml-2">OrderEvent.java</div>
                            </div>
                            <pre class="text-gray-200 p-4 overflow-x-auto"><code>// 自定义订单事件
public class OrderEvent extends ApplicationEvent {
    private String orderId;
    
    public OrderEvent(Object source, String orderId) {
        super(source);
        this.orderId = orderId;
    }
    // getter...
}

// 短信通知监听器
@Component
public class SmsListener implements ApplicationListener<OrderEvent> {
    @Override
    public void onApplicationEvent(OrderEvent event) {
        sendSms(event.getOrderId());
    }
}

// 使用示例
@Service
public class OrderService {
    @Autowired
    private ApplicationEventPublisher publisher;
    
    public void createOrder(Order order) {
        // 创建订单逻辑
        publisher.publishEvent(new OrderEvent(this, order.getId()));
    }
}</code></pre>
                        </div>
                        <p class="text-gray-700">
                            这种解耦设计让系统扩展变得容易。当需要新增邮件通知时，只需添加新的监听器即可，无需修改订单创建逻辑。
                        </p>
                    </div>
                </div>
            </div>

            <!-- Adapter Pattern -->
            <div class="pattern-card bg-white rounded-xl shadow-md overflow-hidden mb-10 transition-all duration-300">
                <div class="md:flex">
                    <div class="md:w-1/3 p-6 flex items-center bg-red-50">
                        <div class="text-center w-full">
                            <div class="pattern-icon inline-block text-red-600 mb-4">
                                <i class="fas fa-plug text-6xl"></i>
                            </div>
                            <h3 class="text-2xl font-bold mb-2">适配器模式</h3>
                            <p class="text-red-700">接口转换的桥梁</p>
                        </div>
                    </div>
                    <div class="md:w-2/3 p-6">
                        <div class="flex items-center mb-4">
                            <div class="w-3 h-3 rounded-full bg-red-500 mr-2"></div>
                            <h4 class="text-xl font-semibold">旅行电源转换插头</h4>
                        </div>
                        <p class="text-gray-700 mb-4">
                            出国旅行时用到的电源转换插头就是适配器的现实版。Spring MVC中的HandlerAdapter就是这个模式的经典应用。
                        </p>
                        <div class="mb-6">
                            <h5 class="font-semibold mb-2 text-red-700 flex items-center">
                                <i class="fas fa-exchange-alt mr-2"></i>适配场景：
                            </h5>
                            <ul class="list-disc pl-5 space-y-1 text-gray-700">
                                <li>控制器方法参数解析</li>
                                <li>返回值处理</li>
                                <li>跨版本接口兼容</li>
                            </ul>
                        </div>
                        <div class="code-block mb-4">
                            <div class="code-header">
                                <div class="code-dot red"></div>
                                <div class="code-dot yellow"></div>
                                <div class="code-dot green"></div>
                                <div class="text-gray-300 text-sm ml-2">PaymentAdapter.java</div>
                            </div>
                            <pre class="text-gray-200 p-4 overflow-x-auto"><code>// 旧版支付接口
public class LegacyPayment {
    public String pay(int amount) {
        return "现金支付：" + amount + "元";
    }
}

// 适配器
@Component
public class PaymentAdapter implements ModernPayment {
    
    private final LegacyPayment legacyPayment;
    
    public PaymentAdapter(LegacyPayment legacyPayment) {
        this.legacyPayment = legacyPayment;
    }
    
    @Override
    public String onlinePay(int amount) {
        String result = legacyPayment.pay(amount);
        return "适配后的结果：" + result;
    }
}

// 现代支付接口
public interface ModernPayment {
    String onlinePay(int amount);
}

// 控制器使用
@RestController
public class PaymentController {
    @Autowired
    private ModernPayment payment;
    
    @PostMapping("/pay")
    public String handlePay(@RequestParam int amount) {
        return payment.onlinePay(amount);
    }
}</code></pre>
                        </div>
                        <p class="text-gray-700">
                            当HandlerAdapter处理不同类型的Controller时（如@Controller与HttpRequestHandler），正是通过适配器模式实现了统一调用。
                        </p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary Section -->
        <section id="summary" class="mb-16">
            <div class="bg-white rounded-xl shadow-md p-8">
                <h2 class="text-3xl font-bold mb-6">设计模式认知的三个阶段</h2>
                <div class="grid md:grid-cols-3 gap-6 mb-8">
                    <div class="border-l-4 border-blue-500 pl-4">
                        <h3 class="text-xl font-semibold mb-2">1. 看山是山</h3>
                        <p class="text-gray-700">在SpringBoot中看到各种注解和配置</p>
                    </div>
                    <div class="border-l-4 border-purple-500 pl-4">
                        <h3 class="text-xl font-semibold mb-2">2. 看山不是山</h3>
                        <p class="text-gray-700">发现背后隐藏的设计模式</p>
                    </div>
                    <div class="border-l-4 border-green-500 pl-4">
                        <h3 class="text-xl font-semibold mb-2">3. 看山还是山</h3>
                        <p class="text-gray-700">理解模式组合带来的架构之美</p>
                    </div>
                </div>
                <div class="mb-6">
                    <h3 class="text-xl font-semibold mb-4">理解设计模式的价值</h3>
                    <p class="text-gray-700 mb-4">
                        当我们理解这些模式后，就能：
                    </p>
                    <ul class="list-disc pl-5 space-y-2 text-gray-700">
                        <li><span class="font-medium">更高效地使用框架特性</span> - 理解原理而非死记硬背</li>
                        <li><span class="font-medium">编写更优雅的代码</span> - 遵循经过验证的设计原则</li>
                        <li><span class="font-medium">快速定位疑难问题</span> - 透过现象看本质</li>
                        <li><span class="font-medium">设计出可扩展的系统架构</span> - 组合模式应对复杂需求</li>
                    </ul>
                </div>
                <div class="bg-blue-50 p-6 rounded-lg">
                    <h4 class="text-lg font-semibold mb-3 text-blue-700 flex items-center">
                        <i class="fas fa-lightbulb mr-2"></i>调试技巧
                    </h4>
                    <p class="text-gray-700">
                        在IDEA中打开"Show Spring Beans"视图（Ctrl+Alt+Shift+U），你会看到单例池中所有Bean的庐山真面目。试着找出本文提到的各个模式实现，这将是你进阶Spring高手的重要一步！
                    </p>
                </div>
            </div>
        </section>

        <!-- Visualization -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-md p-8">
                <h2 class="text-3xl font-bold mb-6">设计模式关系可视化</h2>
                <div class="mermaid">
                    graph TD
                    A[SpringBoot设计模式] --> B[创建型]
                    A --> C[结构型]
                    A --> D[行为型]
                    
                    B --> B1[工厂模式\nBean创建]
                    B --> B2[单例模式\n核心组件]
                    
                    C --> C1[代理模式\nAOP实现]
                    C --> C2[适配器模式\nHandlerAdapter]
                    
                    D --> D1[模板方法模式\nJdbcTemplate]
                    D --> D2[观察者模式\n事件机制]
                    
                    style A fill:#4f46e5,color:white
                    style B fill:#6366f1,color:white
                    style C fill:#818cf8,color:white
                    style D fill:#a5b4fc,color:white
                    
                    style B1 fill:#ec4899,color:white
                    style B2 fill:#f43f5e,color:white
                    style C1 fill:#10b981,color:white
                    style C2 fill:#14b8a6,color:white
                    style D1 fill:#f59e0b,color:white
                    style D2 fill:#f97316,color:white
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-8">
        <div class="container mx-auto px-4 text-center">
            <h3 class="text-xl font-semibold mb-2">技术小馆</h3>
            <p class="mb-4">探索技术本质，品味架构艺术</p>
            <a href="http://www.yuque.com/jtostring" class="text-blue-300 hover:text-white transition duration-300">
                <i class="fas fa-globe mr-1"></i> http://www.yuque.com/jtostring
            </a>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>